<html>
<head><meta charset="utf-8"><title>How to find a type / a function from the context? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20find.20a.20type.20.2F.20a.20function.20from.20the.20context.3F.html">How to find a type / a function from the context?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206939927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20find%20a%20type%20/%20a%20function%20from%20the%20context%3F/near/206939927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jason Hu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20find.20a.20type.20.2F.20a.20function.20from.20the.20context.3F.html#206939927">(Aug 14 2020 at 15:15)</a>:</h4>
<p>I am trying to do some instrumentation inside the compiler in a software engineering project and as a result I want to find a way to get a <code>Ty</code> of a custom defined type. is there a way in the compiler to iterate all loaded types (potentially from other crates)? for illustration purpose, consider the following example:</p>
<div class="codehilite"><pre><span></span><code>struct MyVec&lt;T&gt; { ... }
impl MyVec&lt;T&gt; {
    fn new() -&gt; MyVec&lt;T&gt; { ... }
    // many other Vec functions
}
</code></pre></div>


<p>Here I am implementing part of the vectors. My end goal is that I would like to replace <code>Vec&lt;T&gt;</code> with <code>MyVec&lt;T&gt;</code> everywhere, including method calls. To begin with, I have to find <code>MyVec&lt;T&gt;</code> and its functions. Is there a way to achieve this?</p>



<a name="206949866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20find%20a%20type%20/%20a%20function%20from%20the%20context%3F/near/206949866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20find.20a.20type.20.2F.20a.20function.20from.20the.20context.3F.html#206949866">(Aug 14 2020 at 16:42)</a>:</h4>
<p>The standard way to do this kind of things is adding a new lang item for the type.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>